package com.hx.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

@Configuration
//@PropertySources() 读多个
@PropertySource("classpath:jdbc.properties")
public class DataSourceConfig {
    @Value("${jdbc.url}")
    String url;
    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
       // dataSource.setUrl("jdbc:mysql://localhost:3306/companydb?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&serverTimezone=Asia/Shanghai&allowMultiQueries=true");
        dataSource.setUrl(url);
        dataSource.setUsername("root");
        dataSource.setPassword("199837");
        dataSource.setMaxActive(3000);
        dataSource.setMinIdle(5);
        return dataSource;
    }
}
